package com.healthtop.dao;

import com.healthtop.mapper.XsDictionaryMapper;
import com.healthtop.model.XsDictionary;
import com.healthtop.model.XsDictionaryExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class XsDictionaryDao {

    @Autowired
    private XsDictionaryMapper xsDictionaryMapper;

    public XsDictionary getXsDictionaryById(long id) {
        return xsDictionaryMapper.selectByPrimaryKey(id);
    }

    public void insert(XsDictionary xsDictionary) {
        xsDictionaryMapper.insertSelective(xsDictionary);
    }

    public void update(XsDictionary xsDictionary) {
        xsDictionaryMapper.updateByPrimaryKeySelective(xsDictionary);
    }

    public void delete(XsDictionary xsDictionary) {
        xsDictionaryMapper.updateByPrimaryKeySelective(xsDictionary);
    }

    public List<XsDictionary> selectByType(long type) {
        XsDictionaryExample example = new XsDictionaryExample();
        example.createCriteria().andTypeEqualTo(type).andDelFalgEqualTo("0");
        return xsDictionaryMapper.selectByExample(example);
    }
}
